import 'dart:convert';

/// 生成路由的注释
class RikiRoute {
  const RikiRoute({
    required this.name,
    this.showStatusBar = true,
    this.routeName = '',
    this.pageRouteType,
    this.description = '',
    this.exts,
    this.argumentImports,
    this.transitionMilliseconds,
    this.reverseTransitionMilliseconds,
  });

  /// 路由的名称 (如, "/settings").
  final String name;

  /// 是否显示StatusBar
  final bool showStatusBar;

  /// 跟踪页面的路由名称，用于埋点等
  final String routeName;

  /// 路由跳转方式
  final PageRouteType? pageRouteType;

  /// 路由描述
  final String description;

  /// 拓展参数
  final Map<String, dynamic>? exts;

  /// 包含的参数类型
  ///
  /// argumentImports: <String>[
  ///   'import \'package:example/src/model/test_model.dart\';',
  ///   'import \'package:example/src/model/test_model1.dart\';'
  /// ],
  final List<String>? argumentImports;

  /// 转场动画时长(毫秒)
  final int? transitionMilliseconds;

  /// 反向转场动画时长(毫秒)
  final int? reverseTransitionMilliseconds;

  @override
  String toString() {
    return json.encode(this);
  }

  Map<String, dynamic> toJson() => <String, dynamic>{
        'name': name,
        'showStatusBar': showStatusBar,
        'routeName': routeName,
        'pageRouteType': pageRouteType,
        'description': description,
        'exts': exts,
        'argumentImports': argumentImports,
        'transitionMilliseconds': transitionMilliseconds,
        'reverseTransitionMilliseconds': reverseTransitionMilliseconds,
      };
}

/// 路由的跳转方式
enum PageRouteType {
  material,
  cupertino,
  transparent,
}

// typedef RouteGuard = Future<bool> Function();

const String constructorName = 'constructorName';
